package com.situ.firmadmin.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.firmadmin.mapper.DeptMapper;
import com.situ.firmadmin.pojo.Dept;
import com.situ.firmadmin.pojo.query.DeptQuery;
import com.situ.firmadmin.service.IDeptService;
import com.situ.firmadmin.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements IDeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> selectAll() {
        return deptMapper.selectAll();
    }


    @Override
    public PageResult selectByPage(DeptQuery deptQuery) {
        PageHelper.startPage(deptQuery.getPage(), deptQuery.getLimit());
        List<Dept> list=deptMapper.selectByPage(deptQuery);
        PageInfo<Dept> pageInfo=new PageInfo<>(list);
        int total=(int)pageInfo.getTotal();
        return new PageResult(0,"",total,list);
    }

    @Override
    public void insert(Dept dept) {
        deptMapper.insert(dept);
    }

    @Override
    public Dept selectById(Integer id) {
        return deptMapper.selectById(id);
    }

    @Override
    public void update(Dept dept) {
        deptMapper.update(dept);
    }

    @Override
    public void deleteById(Integer id) {
        deptMapper.deleteById(id);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        deptMapper.deleteAll(ids);
    }
    
    @Override
    public void updateStatus(Dept dept) {
        deptMapper.update(dept);
    }
}
